#include <bits/stdc++.h>
using namespace std;
int T;
int n,m,len,V,ans,cnt;
int d[100005],v[100005],a[100005];
int p[100005];
double nowv(int v0,int add,int s){
	if (add==0)return v0;
	double v1=sqrt(2*add*s+v0*v0);
	return v1;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&T);
	while (T--){
		cnt=0;
		scanf("%d %d %d %d",&n,&m,&len,&V);
		for (int i=1;i<=n;i++){
			scanf("%d %d %d",&d[i],&v[i],&a[i]);
		}
		for (int i=1;i<=m;i++){
			scanf("%d",&p[i]);
		}
		for (int i=1;i<=n;i++){
			if (d[i]<=p[m] && nowv(v[i],a[i],p[m]-d[i])>V)cnt++;
		}
		if (cnt)m--;
		printf("%d %d\n",cnt,m);
	}
	return 0;
}